//
//  BdjlxqVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/11.
//

import Foundation

extension BdjlxqVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing3@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH())
        }
        self.navTitle = "详细信息"
        self.lgf_NavigationBar.style.lgf_TitleColor = UIColor.white
        self.lgf_NavigationBar.lgf_Reload()
        
        let delete = UIButton.init(type: .custom)
        delete.setTitle("删除", for: .normal)
        delete.backgroundColor = UIColor.red
        delete.titleLabel?.textColor = UIColor.white
        delete.addTarget(self, action: #selector(BdjlxqVC.s_delete), for: .touchUpInside)
        view.addSubview(delete)
        delete.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.width.equalToSuperview()
            make.height.equalTo(44)
            make.bottom.equalToSuperview().offset(-UIDevice.lgf_TopSafeAreaH())
        }
        
//        let upload = UIButton.init(type: .custom)
//        upload.setTitle("上传", for: .normal)
//        upload.backgroundColor = UIColor.init(lgf_HexString: "0F88F2")
//        upload.titleLabel?.textColor = UIColor.white
//        upload.addTarget(self, action: #selector(BdjlxqVC.s_upload), for: .touchUpInside)
//        view.addSubview(upload)
//        upload.snp.makeConstraints { (make) in
//            make.right.equalToSuperview()
//            make.width.equalToSuperview().multipliedBy(0.5)
//            make.height.equalTo(44)
//            make.bottom.equalToSuperview().offset(-UIDevice.lgf_TopSafeAreaH())
//        }
        
        scrollView = UIScrollView.lgf_Table("FFFFFF")
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.left.right.equalToSuperview()
            make.bottom.equalTo(delete.snp.top)
        }
        
        let view1 = UIView.init()
        view1.backgroundColor = UIColor.white
        view1.layer.cornerRadius = 8
        view1.layer.shadowColor = UIColor.black.withAlphaComponent(0.3).cgColor
        view1.layer.shadowRadius = 5
        view1.layer.shadowOpacity = 0.4
        view1.layer.shadowOffset = CGSize.init(width: 0, height: 1)
        scrollView.addSubview(view1)
        view1.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(10)
            make.width.equalToSuperview().offset(-20)
            make.centerX.equalToSuperview()
            make.height.equalTo(260)
        }
        
        name = UILabel.init()
        name.text = ""
        name.textAlignment = .center
        name.textColor = UIColor.init(lgf_HexString: "0F88F2")
        view1.addSubview(name)
        name.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(50)
        }
        
        line_view = EWELineScrollView.init(frame: CGRect.init(x: 0, y: 50, w: UIDevice.lgf_ScreenW - 40, h: 200))
        line_view.backgroundColor = UIColor.white
        line_view.layer.borderWidth = 1.0
        line_view.layer.borderColor = UIColor.init(lgf_HexString: "f0f0f0")?.cgColor
        view1.addSubview(line_view)
        line_view.snp.makeConstraints { (make) in
            make.top.equalTo(name.snp.bottom)
            make.width.equalToSuperview().offset(-20)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview().offset(-10)
        }
        line_view.scroll_back.contentSize = CGSize.init(width: 1920 * 8 * Int(powl(2, 5)) / 20, height: 100)
        
        sp_view = UIView.init()
        line_view.scroll_back.addSubview(sp_view)
        sp_view.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.centerY.equalToSuperview().offset(10)
            make.height.equalToSuperview()
            make.width.equalTo(1920 * 8 * Int(powl(2, 5)) / 20)
        }
        
        for i in 0..<100 {
            let sp_view_c = LineBackView2.init()
            sp_view_c.lineColor = UIColor.init(lgf_HexString: "0F88F2")
            sp_view_c.backgroundColor = UIColor.clear
            sp_view.addSubview(sp_view_c)
            sp_view_c.snp.makeConstraints { (make) in
                if i == 0 {
                    make.left.equalToSuperview()
                } else {
                    make.left.equalTo(sp_view.subviews[sp_view.subviews.count - 2].snp.right)
                }
                make.top.bottom.equalToSuperview()
                make.width.equalToSuperview().multipliedBy(0.01)
            }
        }
        
        let view2 = UIView.init()
        scrollView.addSubview(view2)
        view2.snp.makeConstraints { (make) in
            make.top.equalTo(view1.snp.bottom).offset(10)
            make.width.equalToSuperview().offset(-20)
            make.centerX.equalToSuperview()
            make.height.equalTo(60)
        }
        
        play_time = UILabel.init()
        play_time.text = "00:00/00:00"
        play_time.font = UIFont.systemFont(ofSize: 12)
        play_time.textColor = UIColor.init(lgf_HexString: "222222")
        view2.addSubview(play_time)
        play_time.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview()
        }
        
        // 播放
        play_button = UIButton.init(type: .custom)
        play_button.setBackgroundImage(#imageLiteral(resourceName: "bofang"), for: .normal)
        play_button.addTarget(self, action: #selector(BdjlxqVC.playNow(_:)), for: .touchUpInside)
        view2.addSubview(play_button)
        play_button.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview()
            make.width.height.equalTo(25)
        }
        
        play_line = UISlider.init()
        play_line.minimumValue = 0//最小值
        play_line.maximumValue = 1//最大值
        play_line.value = 0 //当前值
        play_line.minimumTrackTintColor = UIColor.init(lgf_HexString: "0F88F2")
        play_line.maximumTrackTintColor = UIColor.init(lgf_HexString: "CFD4D9")
        play_line.thumbTintColor = UIColor.init(lgf_HexString: "0F88F2")
        play_line.addTarget(self, action: #selector(BdjlxqVC.s_end(_:)), for: .touchUpInside)
        play_line.addTarget(self, action: #selector(BdjlxqVC.s_changed(_:)), for: .valueChanged)
        play_line.lgf_AddTap(target: self, action: #selector(BdjlxqVC.s_tap(_:)))
        view2.addSubview(play_line)
        play_line.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.left.equalTo(play_time.snp.right).offset(10)
            make.right.equalTo(play_button.snp.left).offset(-15)
            make.height.equalToSuperview()
        }
        
        let label1 = UILabel.init()
        label1.text = "基本信息"
        label1.textAlignment = .center
        label1.textColor = UIColor.init(lgf_HexString: "222222")
        scrollView.addSubview(label1)
        label1.snp.makeConstraints { (make) in
            make.top.equalTo(view2.snp.bottom)
            make.width.equalToSuperview()
            make.centerX.equalToSuperview()
            make.height.equalTo(50)
        }
        
        let view3 = UIView.init()
        view3.backgroundColor = UIColor.white
        view3.layer.cornerRadius = 8
        view3.layer.shadowColor = UIColor.black.withAlphaComponent(0.3).cgColor
        view3.layer.shadowRadius = 5
        view3.layer.shadowOpacity = 0.4
        view3.layer.shadowOffset = CGSize.init(width: 0, height: 1)
        scrollView.addSubview(view3)
        view3.snp.makeConstraints { (make) in
            make.top.equalTo(label1.snp.bottom).offset(10)
            make.width.equalToSuperview().offset(-20)
            make.centerX.equalToSuperview()
            make.height.equalTo(320)
        }
        
        sg = UILabel.init()
        sg.text = "身高："
        sg.font = UIFont.systemFont(ofSize: 14)
        sg.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(sg)
        sg.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        tz = UILabel.init()
        tz.text = "体重："
        tz.font = UIFont.systemFont(ofSize: 14)
        tz.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(tz)
        tz.snp.makeConstraints { (make) in
            make.top.equalTo(sg.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        tw = UILabel.init()
        tw.text = "体位："
        tw.font = UIFont.systemFont(ofSize: 14)
        tw.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(tw)
        tw.snp.makeConstraints { (make) in
            make.top.equalTo(tz.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        phcd = UILabel.init()
        phcd.text = "配合程度："
        phcd.font = UIFont.systemFont(ofSize: 14)
        phcd.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(phcd)
        phcd.snp.makeConstraints { (make) in
            make.top.equalTo(tw.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        sfzj = UILabel.init()
        sfzj.text = "是否镇静："
        sfzj.font = UIFont.systemFont(ofSize: 14)
        sfzj.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(sfzj)
        sfzj.snp.makeConstraints { (make) in
            make.top.equalTo(phcd.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        sfss = UILabel.init()
        sfss.text = "是否手术："
        sfss.font = UIFont.systemFont(ofSize: 14)
        sfss.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(sfss)
        sfss.snp.makeConstraints { (make) in
            make.top.equalTo(sfzj.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        cjcs = UILabel.init()
        cjcs.text = "采集场所："
        cjcs.font = UIFont.systemFont(ofSize: 14)
        cjcs.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(cjcs)
        cjcs.snp.makeConstraints { (make) in
            make.top.equalTo(sfss.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        cjdz = UILabel.init()
        cjdz.text = "采集地址："
        cjdz.font = UIFont.systemFont(ofSize: 14)
        cjdz.textColor = UIColor.init(lgf_HexString: "222222")
        view3.addSubview(cjdz)
        cjdz.snp.makeConstraints { (make) in
            make.top.equalTo(cjcs.snp.bottom)
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.height.equalTo(40)
        }
        
        scrollView.lgf_AutoContentSize(40)
    }
    
}
